package com.zhangzhiyuan.edu.Controller;

import com.zhangzhiyuan.edu.service.IDemoService;
import com.zhangzhiyuan.mvcframework.annotations.LagouAutowied;
import com.zhangzhiyuan.mvcframework.annotations.LagouController;
import com.zhangzhiyuan.mvcframework.annotations.LagouRequestMapping;
import com.zhangzhiyuan.mvcframework.annotations.Security;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@LagouController
@LagouRequestMapping("/demo")
//@Security({"yxh","daj"})
public class DemoController {

    @LagouAutowied
    private IDemoService iDemoService;

    @LagouRequestMapping("/query")
    @Security({"11"})
    public String query(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse,String username) throws IOException {
        httpServletResponse.setContentType("text/html;charset=utf-8");

        String s = iDemoService.get(username);
        httpServletResponse.getWriter().write("专门用来测试query==>才能11访问");
        return "专门用来测试query";
    }
    @LagouRequestMapping("/queryList")
    @Security({"22"})
    public String queryList(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse,String username) throws IOException {
        String s = iDemoService.get(username);
        httpServletResponse.setContentType("text/html;charset=utf-8");
        if(username==null){
            httpServletResponse.getWriter().write("请携带username");
        }
        httpServletResponse.getWriter().write("queryList==>22才能访问");
        return "专门用来测试queryList";
    }

}
